package com.fzj.ivos_serve.vehicle.controller;

import com.fzj.ivos_serve.base.response.JsonResult;
import com.fzj.ivos_serve.vehicle.pojo.dto.VehicleQuery;
import com.fzj.ivos_serve.vehicle.pojo.dto.VehicleSaveParam;
import com.fzj.ivos_serve.vehicle.pojo.vo.VehicleVO;
import com.fzj.ivos_serve.vehicle.service.VehicleService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RequestMapping("/v1/vehicle")
@RestController
@Slf4j
public class VehicleController {
    @Autowired
    private VehicleService vehicleService;
    @PostMapping("save")
    public JsonResult save(VehicleSaveParam vehicleSaveParam){
        log.debug("保存车辆信息，参数：{}",vehicleSaveParam);
        vehicleService.saveVehicle(vehicleSaveParam);
        return JsonResult.ok();
    }
    @GetMapping("select")
    public JsonResult select(VehicleQuery vehicleQuery){
        log.debug("查询车辆信息，参数：{}",vehicleQuery);
        List<VehicleVO> vehicleVOList = vehicleService.selectVehicle(vehicleQuery);
        return JsonResult.ok(vehicleVOList);
    }
    @PostMapping("deleteById/{id}")
    public JsonResult deleteById(@PathVariable Long id){
        log.debug("根据id删除车辆");
        vehicleService.deleteVehicleById(id);
        return JsonResult.ok();
    }

}
